package com.tengju.bff.infrastructure.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

/**
 * @Author: 李大仙
 * @Date: 2021/3/24 1:05 下午
 */
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.tengju.*.domain.service")
public class ElasticsearchConfig {

    private final RestHighLevelClient client;

    @Autowired
    public ElasticsearchConfig(RestHighLevelClient client) {
        this.client = client;
    }

    @Bean
    ElasticsearchOperations elasticsearchTemplate() {
        return new ElasticsearchRestTemplate(client);
    }
}
